<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:c="http://java.sun.com/jsp/jstl/core"
                template="/template/OutletManagementTemplate.xhtml">

    <ui:define name="contentInsert">

        <h3>Redeem Deals and Vouchers</h3>


        <p:tabView>
            <p:tab  title="Redeem a Customer's Group Deal Coupons">
                 <p:ajaxStatus style="width:16px;height:16px;">
                        <f:facet name="start">
                            <h:graphicImage value="http://www.primefaces.org:8080/showcase/design/ajaxloading.gif" />
                        </f:facet>
                        <f:facet name="complete">
                            <h:outputText value="" />
                        </f:facet>
                    </p:ajaxStatus>
                    <p:messages />

                <h:form id="form_redeemgroupon">
                    
                    <br/>
                    <br/>
                    Input Customer Email: <p:inputText value="#{outletManagerIOTRManagedBean.customerEmail}"/>  <p:commandButton value="Get Deal Items" action="./" ajax="true" update="form_redeemgroupon"/>
                    <br/>
                    <br/>
                    <p:dataTable value="#{outletManagerIOTRManagedBean.getGrouponItem()}" var="o"  paginator="true" rows="25"
                                 emptyMessage="Nothing to display"
                                 style="font-size: 10px"
                                 >


                        <p:column>
                            <f:facet name="header">Purchase<br/> Date</f:facet>
                #{o.time_stamp.time}
                        </p:column>

                        <p:column>
                            <f:facet name="header">Seller</f:facet>
                    #{o.seller}
                        </p:column>

                        <p:column>
                            <f:facet name="header">Deal</f:facet>
                    #{o.item_name}
                        </p:column>

                        <p:column style="width:40%">
                            <f:facet name="header">Description</f:facet>
                    #{o.item_description}
                        </p:column>

                        <p:column>
                            <f:facet name="header">Coupons <br/>Purchased</f:facet>
                                #{o.quantity}
                        </p:column>

                        <p:column>
                            <f:facet name="header">Coupons <br/>Redeemed</f:facet>
                                #{o.noRedeemed}
                        </p:column>

                        <p:column style="width: 40px">
                            <f:facet name="header">Coupons to <br/>redeem</f:facet>
                            <p:inputText value="#{outletManagerIOTRManagedBean.noToRedeem}" validatorMessage="Negative Number is not allowed">
                                <f:validateDoubleRange minimum="0"/>    
                            </p:inputText>    
                            <br/>
                            <p:commandButton value="Redeem" action="#{outletManagerIOTRManagedBean.redeemGroupon(o.id)}" ajax="false"/>
                        </p:column>



                    </p:dataTable>
                </h:form> 

            </p:tab><!--******************************************************-->




            <p:tab title="Redeem a Customer's Reward Vouchers">
                <h:form id="form_voucherRedeem">
                    <br/>
                    <br/>
                    Input Customer Email: <p:inputText value="#{rewardMB.customerEmail}"/>  <p:commandButton value="Get Vouchers" action="./" ajax="true" update="form_voucherRedeem"/>
                    <br/>
                    <br/>
                    <p:dataTable value="#{rewardMB.getCustomerVouchers()}" var="o" paginator="true" rows="25"
                                 emptyMessage="Nothing to display"
                                 style="font-size: 10px"
                                 >


                        <p:column style="width: 10px">
                            <f:facet name="header">ID</f:facet>
                                                        #{o.id}
                        </p:column>


                        <p:column style="width: 50px">
                            <f:facet name="header">Name</f:facet>
                                                        #{o.reward_Name}
                        </p:column>

                        <p:column style="width: 80px">
                            <f:facet name="header">Description</f:facet>
                            <h:outputText value="#{o.reward_Description}" escape="false"/>

                        </p:column>

                        <p:column style="width: 40px">
                            <f:facet name="header">Points <br/>Cost</f:facet>
                                                        #{o.reward_Cost}
                        </p:column>

                        <p:column style="width: 40px">
                            <f:facet name="header">Purchase <br/>Date</f:facet>
                                                        #{o.purchaseDate}
                        </p:column>

                        <p:column style="width: 50px">                    
                            <p:commandButton value="Redeem" action="#{rewardMB.redeemVoucher(o.id)}" ajax="false"/>
                        </p:column>


                    </p:dataTable>

                </h:form>  
            </p:tab><!--******************************************************-->
        </p:tabView>
        
        
        
        
        
        
 
    </ui:define>
</ui:composition>
